package com.yl.chainStore.entity.pay

import com.baomidou.mybatisplus.annotation.IdType
import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import com.yl.chainStore.common.Constants
import com.yl.common.annotation.NoArg
import java.math.BigDecimal
import java.math.RoundingMode
import java.util.*

/**
 * <p>
 *
 * </p>
 *
 * @author cxw
 * @since 2021-09-20
 */
@NoArg
@TableName("pay_customer_order_discount_log")
    data class PayCustomerOrderDiscountLog  (

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    var id: Long,

    /**
     * 订单id
     */
    @TableField("order_id")
    var orderId: Long,

    /**
     * 客户id
     */
    @TableField("customer_id")
    var customerId: Long,

    /**
     * 用户id
     */
    @TableField("create_user_id")
    var createUserId: Long,

    /**
     * 规则id
     */
    @TableField("rule_id")
    var ruleId: Long,

    /**
     * 内容
     */
    @TableField("content")
    var content: String,

    /**
     * 折扣金额
     */
    @TableField("discount_money")
    var discountMoney: Long = 0,

    /**
     * 创建时间
     */
    @TableField("create_time")
    var createTime:Date ?= Date()

){
    @TableField(exist = false)
    var discountMoneyShow: BigDecimal?= null
        get() {

            if(field == null){
                return BigDecimal(discountMoney.div(Constants.OtherConfig.MONEY_TO_DB_DOUBLE)).setScale(2, RoundingMode.HALF_UP)
            }
            return field
        }

    }
